﻿@model IEnumerable<SDSystem.Models.Premise>
@using Ext.Net
@using Ext.Net.MVC
@{
    ViewBag.Title = "ListPremises";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@(Html.X().GridPanel().ID("PremiseDataGridPanel")
                                .Frame(true)
                                .Store(Html.X().Store().ID("PremisesListStore")
                                        .Model(Html.X().Model().IDProperty("PremiseId")
                                        .Fields(
                                            new ModelField("PremiseId",ModelFieldType.Int),
                                            new ModelField("PremiseName"),
                                            new ModelField("AddressLine1"),
                                            new ModelField("PhoneNumber"),
                                            new ModelField("ProjectCode")
                                        )
                                    )
                                    .RemoteSort(true)
                                    .RemotePaging(true)
                                    .PageSize(15)
                                    .Proxy(
                                                Html.X().AjaxProxy()
                                                    .Url(Url.Action("BindingStore11"))
                                                    .Reader(Html.X().JsonReader().Root("data"))
                                            )


                                )
                                .ColumnModel(
                                            Html.X().Column().Text("ID").DataIndex("PremiseId").Flex(1),
                                            Html.X().TemplateColumn().Text("Premise Name").TemplateString("<a href='javascript:void(0)' onclick='showWindow(\"Edit Premise\",\"/Premises/Edit/\" + {PremiseId}, true, 0.85, 0.85);'>{PremiseName}</a>").Flex(2),
                                            //Html.X().Column().Text("Location Name").DataIndex("LocationName").Flex(2),
                                            Html.X().Column().Text("Address Line").DataIndex("AddressLine1").Flex(2),
                                            Html.X().Column().Text("Phone Number").DataIndex("PhoneNumber").Flex(1),
                                            Html.X().Column().Text("Project Code").DataIndex("ProjectCode").Flex(1),
                                            Html.X().CommandColumn().Width(50).Commands(
                                                    Html.X().GridCommand().CommandName("Add").Icon(Icon.Add).ToolTip(tt => tt.Text = "Delete"))
                                                                .Listeners(ls => ls.Command.Handler = "#{DirectMethods}.AddPremiseLink(record.data.PremiseId);").Flex(1)
                                            

      ).BottomBar( Html.X().PagingToolbar().Items(
                       Html.X().Button().Text("Close").Icon(Icon.Accept).Listeners(ls => ls.Click.Handler = "window.parent.location.reload();parentAutoLoadControl.close();")
      )))
